package com.bigdata.movieticketapi.controller;

import com.bigdata.movieticketapi.common.pojo.PageResult;
import com.bigdata.movieticketapi.entity.Movie;
import com.bigdata.movieticketapi.entity.MovieSession;
import com.bigdata.movieticketapi.service.IMovieSessionService;
import com.bigdata.movieticketapi.vo.req.*;
import com.bigdata.movieticketapi.vo.resp.MovieSessionDetailRespVO;
import com.bigdata.movieticketapi.vo.resp.PageMovieRespVO;
import com.bigdata.movieticketapi.vo.resp.PageMovieSessionRespVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author movie
 * @since 2023-11-09
 */
@RestController
@RequestMapping("/api")
@Api(tags = "电影场次模块")
public class MovieSessionController {

    @Resource
    private IMovieSessionService iMovieSessionService;

    @PostMapping("/admin/movieSession/add")
    @ApiOperation(value = "添加电影场次")
    public void addMovie(@RequestBody @Valid MovieSessionReqVO vo){
        iMovieSessionService.addMovieSession(vo);
    }

    @PostMapping("/admin/movieSession/edit")
    @ApiOperation(value = "编辑电影场次")
    public void updateMovie(@RequestBody @Valid MovieSession movieSession){
        iMovieSessionService.updateMovieSession(movieSession);
    }

    @PostMapping("/admin/movieSession")
    @ApiOperation(value = "场次分页接口")
    public PageResult<PageMovieSessionRespVO> pageMovies(@RequestBody @Valid PageMovieSessionReqVO vo){
        return iMovieSessionService.pageMovieSessions(vo);
    }

    @PostMapping("/uniApp/movieSession")
    @ApiOperation(value = "电影场次分页接口")
    public PageResult<PageMovieSessionRespVO> pageMoviesById(@RequestBody @Valid GetDataByIdReqVo vo){
        return iMovieSessionService.pageMovieSessionsById(vo);
    }

    @PostMapping("/uniApp/session/detail")
    @ApiOperation(value = "电影场次详情")
    public MovieSessionDetailRespVO getSessionDetailById(@RequestBody @Valid GetDataByIdReqVo vo){
        return iMovieSessionService.getSessionDetailById(vo);
    }
}
